<?php
/**
 * Created by PhpStorm.
 * User: FDG367
 * Date: 2018/4/8
 * Time: 13:35
 */
namespace common\models;
use Yii;
use yii\db\ActiveRecord;

class NavigationIdentification extends ActiveRecord{
	const IS_SHOW	=1;
	const NO_SHOW	=0;
	public static function tableName(){
		return '{{%navigation_identification}}';
	}

	//获取需要展示的分类
	public static function getCategory(){
		return self::find()->where(['is_show'=>self::IS_SHOW])->asArray()->all();
	}

	/**
	 * @param $id
	 * @return array|null|ActiveRecord
	 */
	public static function getCategoryOther($id){
		return self::find()->where([
			'is_show'=>self::IS_SHOW,
			'id'=>$id,
		])
		->asArray()->one();
	}

	/**
	 * @param $parents_id
	 * @return array|\yii\db\ActiveRecord[]
	 */
	public static function getCategoryOtherParents($parents_id){
		return self::find()->where([
			'is_show'=>self::IS_SHOW,
			'parent_id'=>$parents_id,
		])
			->orderBy(['sort'=>SORT_DESC])
			->asArray()->all();
	}

    //获取标示记录
    public static function getNavigationName($id){
        return self::find()->where(['id'=>$id])->asArray()->one();
    }
}
?>